<?php

$alphabet = @$_GET['alphabet'];
$listfilter = "";
$listfilter = @$_GET['listfilter'];
$WhereFilter = "";
$listfilter_htmlcode = $PACTS_cfg->remove_duplicated_amps("listfilter=".$listfilter."&amp;");

if ($alphabet==null or $alphabet == ""){
    $alphabet="all";
}
$alphabet_htmlcode = 'alphabet='.$alphabet.'';


$WhereFilter = $PACTS_cfg->getListHeader($listfilter_htmlcode,$alphabet,"index.php?view=Indv_az_list","index.php?view=Indv_allentries","Individuals",$listfilter,&$WhereFilter);
//echo "<h3>$WhereFilter</h3>" ;
$link = 'Indv_az_list.php?alphabet='.$alphabet.'&amp;';


$WhereFilter = "TRUE ".$WhereFilter;
echo '<div id="main_content">'."\n";

$sql = "SELECT * FROM $PACTS_cfg->individualtablename WHERE  TRUE ";
if (strtoupper($alphabet)!="ALL"){
    $sql .= "AND (Surname LIKE '".strtoupper($alphabet)."%' OR Surname LIKE '".strtolower($alphabet)."%') ";
}
$sql .= "AND $WhereFilter ORDER BY Surname";

$result = mysql_query($sql,$PACTS_cfg->dblink);

$resultsnumber = mysql_num_rows($result);
$alternate = "2";
echo '<p id="desc1">Number of entries: '.$resultsnumber.'</p>'."\n";

if($resultsnumber>0){
    echo '<table class="listType1">'."\n";//cellpadding=2 cellspacing=1 border=0>";
    //echo '<thead>'."\n";
    //echo '<thead>'."\n";
    //echo '<thead>'."\n";
    //echo '</thead>'."\n";
    while  ($row = mysql_fetch_array($result))
    {

        $IndividualId = $row["IndividualId"];
        $FamilyId = $row["FamilyId"];

        $firstname = $row["FirstName"];
        $lastname = $row["Surname"];
        $role = $row["RoleTypeCode"];

        echo $PACTS_cfg->getIndvNavBar($IndividualId."&amp;".$listfilter_htmlcode.$alphabet_htmlcode, $FamilyId, TRUE, TRUE, TRUE, "Indv_az_list","alphabet=$alphabet",TRUE,$lastname.', '.$firstname."\n".'<i>('.$role.')</i>'."\n");
        echo"</tr>";

    }
    echo "</table>";
} else
{
    echo "&nbsp;<br />Sorry - no entries under this letter<p>";
}

echo '</div>'."\n";

?> 

<p><a href="index.php?view=Indv_az_index">Back to alphabet list</a></p>